package com.ruoyi.web.controller.alipay;
import com.ruoyi.weixin.domain.KssUserPay;
import com.ruoyi.weixin.domain.OrderDetail;
import com.ruoyi.weixin.service.IKssUserPayService;
import com.ruoyi.weixin.service.IOrderDetailService;
import com.ruoyi.weixin.vo.PayVo;
import com.ruoyi.weixin.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 徐柯
 * @Title:
 * @Package
 * @Description:
 * @date 2021/5/1022:59
 */
@RestController
public class AlipayMonitorController {

    @Autowired
    private IOrderDetailService orderDetailService;

    /**
     * 定义监听类
     * @return
     */
    @ResponseBody
    @RequestMapping("/api/order/detail/callback")
    public R listenerCallback(@RequestBody PayVo payVo) {
        OrderDetail orderDetail = new OrderDetail();
        orderDetail.setUserId("1");
        orderDetail.setCourseId(payVo.getCourseid());
        List<OrderDetail> list = orderDetailService.selectOrderDetailList(orderDetail);
        return list.size() > 0 ? R.ok() : R.error();
   }

    @ResponseBody
    @RequestMapping("/api/code")
    public R insertCode(String code) {
//        String code = map.get("code").toString();
        System.out.println(code);
        OrderDetail orderDetail = new OrderDetail();
        orderDetail.setUserId("1");
        List<OrderDetail> list = orderDetailService.selectOrderDetailList(orderDetail);
        return list.size() > 0 ? R.ok() : R.error();
    }

}